package com.yadang.optional;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.io.StringReader;
import java.util.List;

/**
 * @author: 亚当
 * @date: 2023年03月22日 0:20
 * @package: com.yadang.optional
 * @Description: TODO
 */
public class test {
    public static void main(String[] args) {
        String xmlData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "<Msg>\n" +
                "    <Header>\n" +
                "        <Vrsn>\n" +
                "            <VrsnID>1.0</VrsnID>\n" +
                "        </Vrsn>\n" +
                "        <Sndr>\n" +
                "            <SndrId>CCDC</SndrId>\n" +
                "        </Sndr>\n" +
                "        <Rcvr>\n" +
                "            <RcvrId>DCSM</RcvrId>\n" +
                "            <RcvrClntId>0000000012</RcvrClntId>\n" +
                "        </Rcvr>\n" +
                "        <FileDesc>\n" +
                "            <FileSndDateTime>2023-03-20 02:26:15</FileSndDateTime>\n" +
                "            <FileType>xml</FileType>\n" +
                "            <FileName>托管账户总对账报告（细分科目）资产托管_20230320022615.xml</FileName>\n" +
                "        </FileDesc>\n" +
                "    </Header>\n" +
                "    <Body>\n" +
                "        <Record>\n" +
                "            <BIZ_DATE>2023-03-19</BIZ_DATE>\n" +
                "            <BOND_ACCT>00000012647</BOND_ACCT>\n" +
                "            <BOND_ACCT_NAME_ABBR>矧猎洱袜并啮腰目卫</BOND_ACCT_NAME_ABBR>\n" +
                "            <BOND_CODE>180017</BOND_CODE>\n" +
                "            <BOND_NAME_ABBR>85募息钵草63</BOND_NAME_ABBR>\n" +
                "            <DENOMINATED_CURRENCY_DESC>人民币</DENOMINATED_CURRENCY_DESC>\n" +
                "            <SUBJ_SET>\n" +
                "                <BOND_SUBJ_NAME>可用</BOND_SUBJ_NAME>\n" +
                "                <SUBJ_FACE_AMNT>0</SUBJ_FACE_AMNT>\n" +
                "                <SUBJ_BAL_UNIT_DESC>万元</SUBJ_BAL_UNIT_DESC>\n" +
                "                <BOND_SUBJ_NAME>质权</BOND_SUBJ_NAME>\n" +
                "                <SUBJ_FACE_AMNT>0</SUBJ_FACE_AMNT>\n" +
                "                <SUBJ_BAL_UNIT_DESC>万元</SUBJ_BAL_UNIT_DESC>\n" +
                "            </SUBJ_SET>\n" +
                "        </Record>\n" +
                "        <Record>\n" +
                "            <BIZ_DATE>2023-03-19</BIZ_DATE>\n" +
                "            <BOND_ACCT>00000050731</BOND_ACCT>\n" +
                "            <BOND_ACCT_NAME_ABBR>建士裕慑鲍苏糍亨锻妤定翅糍</BOND_ACCT_NAME_ABBR>\n" +
                "            <BOND_CODE>130240</BOND_CODE>\n" +
                "            <BOND_NAME_ABBR>35圏播88</BOND_NAME_ABBR>\n" +
                "            <DENOMINATED_CURRENCY_DESC>人民币</DENOMINATED_CURRENCY_DESC>\n" +
                "            <SUBJ_SET>\n" +
                "                <BOND_SUBJ_NAME>质权</BOND_SUBJ_NAME>\n" +
                "                <SUBJ_FACE_AMNT>0</SUBJ_FACE_AMNT>\n" +
                "                <SUBJ_BAL_UNIT_DESC>万元</SUBJ_BAL_UNIT_DESC>\n" +
                "                <BOND_SUBJ_NAME>可用</BOND_SUBJ_NAME>\n" +
                "                <SUBJ_FACE_AMNT>10000</SUBJ_FACE_AMNT>\n" +
                "                <SUBJ_BAL_UNIT_DESC>万元</SUBJ_BAL_UNIT_DESC>\n" +
                "            </SUBJ_SET>\n" +
                "        </Record>\n" +
                "        <Record>\n" +
                "            <BIZ_DATE>2023-03-19</BIZ_DATE>\n" +
                "            <BOND_ACCT>00000016393</BOND_ACCT>\n" +
                "            <BOND_ACCT_NAME_ABBR>滨福氰敷羼材苯敷</BOND_ACCT_NAME_ABBR>\n" +
                "            <BOND_CODE>1828006</BOND_CODE>\n" +
                "            <BOND_NAME_ABBR>85锘条车换矮措31</BOND_NAME_ABBR>\n" +
                "            <DENOMINATED_CURRENCY_DESC>人民币</DENOMINATED_CURRENCY_DESC>\n" +
                "            <SUBJ_SET>\n" +
                "                <BOND_SUBJ_NAME>质权</BOND_SUBJ_NAME>\n" +
                "                <SUBJ_FACE_AMNT>0</SUBJ_FACE_AMNT>\n" +
                "                <SUBJ_BAL_UNIT_DESC>万元</SUBJ_BAL_UNIT_DESC>\n" +
                "            </SUBJ_SET>\n" +
                "        </Record>\n" +
                "        <Record>\n" +
                "            <BIZ_DATE>2023-03-19</BIZ_DATE>\n" +
                "            <BOND_ACCT>00000036568</BOND_ACCT>\n" +
                "            <BOND_ACCT_NAME_ABBR>赔活咸拖3伶w铆</BOND_ACCT_NAME_ABBR>\n" +
                "            <BOND_CODE>200017</BOND_CODE>\n" +
                "            <BOND_NAME_ABBR>71集息癌铸46</BOND_NAME_ABBR>\n" +
                "            <DENOMINATED_CURRENCY_DESC>人民币</DENOMINATED_CURRENCY_DESC>\n" +
                "            <SUBJ_SET>\n" +
                "                <BOND_SUBJ_NAME>质权</BOND_SUBJ_NAME>\n" +
                "                <SUBJ_FACE_AMNT>0</SUBJ_FACE_AMNT>\n" +
                "                <SUBJ_BAL_UNIT_DESC>万元</SUBJ_BAL_UNIT_DESC>\n" +
                "                <BOND_SUBJ_NAME>可用</BOND_SUBJ_NAME>\n" +
                "                <SUBJ_FACE_AMNT>0</SUBJ_FACE_AMNT>\n" +
                "                <SUBJ_BAL_UNIT_DESC>万元</SUBJ_BAL_UNIT_DESC>\n" +
                "            </SUBJ_SET>\n" +
                "        </Record>\n" +
                "    </Body>\n" +
                "</Msg>\n";

        try {
            JAXBContext jaxbContext = JAXBContext.newInstance(CcdcMsg.class);
            Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

            StringReader reader = new StringReader(xmlData);
            CcdcMsg accountReport = (CcdcMsg) unmarshaller.unmarshal(reader);
            List<Record> records = accountReport.getRecords();
            System.out.println(records);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
